<template>
  <div class="user-manage">
    <el-card>
      <div slot="header" class="clearfix">
        <span>用户管理</span>
        <el-button style="float: right;" type="primary" size="small" @click="handleAdd">新增用户</el-button>
      </div>
      <el-table :data="users" style="width: 100%">
        <el-table-column prop="id" label="ID" width="80" />
        <el-table-column prop="username" label="用户名" />
        <el-table-column prop="email" label="邮箱" />
        <el-table-column label="操作" width="180">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.row)">编辑</el-button>
            <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'UserManage',
  data() {
    return {
      users: [
        { id: 1, username: 'admin', email: 'admin@example.com' },
        { id: 2, username: 'user1', email: 'user1@example.com' }
      ]
    }
  },
  methods: {
    handleAdd() {
      this.$message.info('新增用户功能待实现');
    },
    handleEdit(row) {
      this.$message.info('编辑用户功能待实现: ' + row.username);
    },
    handleDelete(row) {
      this.$confirm('确定要删除该用户吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.users = this.users.filter(u => u.id !== row.id);
        this.$message.success('删除成功');
      }).catch(() => {});
    }
  }
}
</script>

<style scoped>
.user-manage {
  padding: 24px;
}
</style> 